[assembly: System.Web.UI.TagPrefix("PersianDateControls", "pdc")]
namespace PersianDateControls
{
    [System.ComponentModel.DefaultProperty("DateValue")]
    [System.Drawing.ToolboxBitmap(typeof(System.Web.UI.WebControls.Label))]
    [System.Web.UI.ToolboxData("<{0}:PersianDateLabel runat=server></{0}:PersianDateLabel>")]
    public sealed class PersianDateLabel : System.Web.UI.WebControls.Label
    {
        public override string Text
        {
            get
            {
                return base.Text;
            }
            set
            {
                if (Convertor.ToGregorianDate(value) != null || value == string.Empty)
                    base.Text = value;
            }
        }

        public object DateValue
        {
            get
            {
                return Convertor.ToGregorianDate(base.Text);
            }
            set
            {
                base.Text = (value == null || value.GetType().FullName == "System.DateTime" ? Convertor.ToPersianDate((System.DateTime?)value) : string.Empty);
            }
        }
    }
}
